<?php

class SessionManager {
	
	/**
	 * 
	 */
	private function __construct() {

	}
	
	static function &getInstance() {
		static $instance;
		
		if ( !isset ( $instance )) {
			$instance = new SessionManager( );
		}

		return $instance;
	}
	
	public function addToSession ( $_name, $_object, $_overwrite = FALSE ) {
		if ( isset( $_SESSION[$_name] ) && !$_overwrite ) {
			throw ObjectExistException ( $_name );
		} else {
			$_SESSION[$_name] = $_object;
		}
	}
	
	public function removeFromSession ( $_name ) {
		if ( isset( $_SESSION[$_name] ) ) {
			$_SESSION[$_name] = NULL;
			unset($_SESSION[$_name]);
			return TRUE;
		}
		return FALSE;
	}
	
	public function getFromSession ( $_name ) {
		if ( isset( $_SESSION[$_name] ) ) {
			return $_SESSION[$_name];
		}
		return NULL;
	}
}

?>